﻿using CommunityToolkit.Mvvm.ComponentModel;
using MeasureAbstract.Base;
using MeasureAbstract.IFarfieldMeasure;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace MeasureAbstract.ISilentAreaMeasure
{
    [INotifyPropertyChanged]
    public abstract partial class ISilentAreaMeasure : IMeasureBase
    {
        /// <summary>
        /// 测量名称
        /// </summary>
        public abstract string MeasureName { get; }

        /// <summary>
        /// 测量描述
        /// </summary>
        public abstract string Description { get; }

        /// <summary>
        /// 本DLL的版本号
        /// </summary>
        public abstract string Version { get; }

        /// <summary>
        /// 测量用到的设备列表
        /// </summary>
        private ObservableCollection<IDeviceBase> _DeviceList;
        public ObservableCollection<IDeviceBase> DeviceList
        {
            get { return _DeviceList; }
            set { SetProperty(ref _DeviceList, value); }
        }

        /// <summary>
        /// 测量进度
        /// </summary>
        public abstract double Process { get; set; }

        /// <summary>
        /// 继续测量
        /// </summary>
        public abstract void MeasureContinue();

        /// <summary>
        /// 测量初始化
        /// </summary>
        public abstract Task MeasureInitialize(object obj);

        /// <summary>
        /// 暂停测量
        /// </summary>
        public abstract void MeasurePause();

        /// <summary>
        /// 重置测量
        /// </summary>
        public abstract void MeasureReset();

        /// <summary>
        /// 开始测量
        /// </summary>
        /// <param name="Type"></param>
        /// <returns></returns>
        public abstract Task MeasureStart(object Type);

        /// <summary>
        /// 停止测量
        /// </summary>
        public abstract void MeasureStop();

        /// <summary>
        /// 保存数据
        /// </summary>
        public abstract void SaveData(object obj);









        //测量过程相关





        //安全相关过程处理





        //测量信息相关






        //不确定度相关

        public Flag Flag=new Flag();


        [ObservableProperty]
        private string antennaName = "";

        [ObservableProperty]
        private string antennaModel = "";

        [ObservableProperty]
        private string polarizationDirection = "水平极化";

        [ObservableProperty]
        private string note = "";


        [ObservableProperty]
        private bool realTimeSave = true;

        [ObservableProperty]
        private string fileName = DateTime.Now.ToString("yyyyMMdd");

        [ObservableProperty]
        private string fileType = "txt";

        /// <summary>
        /// 文件保存路径
        /// </summary>
        [ObservableProperty]
        private string dataFilePath = "";

        public ManualResetEvent ManualResetEvent = new ManualResetEvent(true);
        public bool StopFlag = false;
        public bool InitBreak = false;

        public MeasureData MeasureData = new MeasureData();
        public RealTimeCache RealTimeCache = new RealTimeCache();

        //可能用到的外部数据
        public dynamic SystemConfig { get; set; }
        public dynamic ExternalData { get; set; }


        //数据记录
        /// <summary>
        /// 数据记录，频率响应时用
        /// </summary>
        public Dictionary<double, ObservableCollection<DataItem>> DataDictPosition_FrequencyCollection;

        /// <summary>
        /// 数据记录
        /// </summary>
        public Dictionary<double, ObservableCollection<DataItem>> DataDictFrequency_PositionCollection;

        [ObservableProperty]
        private ObservableCollection<double> frequencyList;

        /// <summary>
        /// 生成报告
        /// </summary>
        [ObservableProperty]
        private IReport.IReport report;

    }

    //public class DataItem
    //{
    //    /// <summary>
    //    /// 位置
    //    /// </summary>
    //    [DisplayName("方位")]
    //    public double Azimuth { get; set; } = 0d;

    //    [DisplayName("俯仰")]
    //    public double Pitching { get; set; } = 0d;

    //    [DisplayName("极化")]
    //    public double Polarization { get; set; } = 0d;

    //    [DisplayName("左右")]
    //    public double X { get; set; } = 0d;

    //    [DisplayName("上下")]
    //    public double Y { get; set; } = 0d;

    //    [DisplayName("前后")]
    //    public double Z { get; set; } = 0d;

    //    /// <summary>
    //    /// 频率
    //    /// </summary>
    //    /// 
    //    [DisplayName("频率")]
    //    public double Frequency { get; set; } = 0d;

    //    /// <summary>
    //    /// 幅度值
    //    /// </summary>
    //    [DisplayName("对数幅度")]
    //    public double LogarithmicAmplitude { get; set; } = 0;

    //    /// <summary>
    //    /// 相位值
    //    /// </summary>
    //    [DisplayName("相位")]
    //    public double Phase { get; set; } = 0;

    //    [DisplayName("线性幅度")]
    //    public double LinearAmplitude { get; set; } = 0;

    //    [DisplayName("实部")]
    //    public double RealPart { get; set; } = 0;

    //    [DisplayName("虚部")]
    //    public double ImaginaryPart { get; set; } = 0;

    //    [DisplayName("驻波比")]
    //    public double StandingWaveRatio { get; set; } = 0;

    //    [DisplayName("群延时")]
    //    public double GroupDelay { get; set; } = 0;

    //}

    //public class MeasureData
    //{
    //    public string MeasurementTime { get; set; } = "";
    //    public string MeasurementType { get; set; } = "";
    //    public string MeasurementParameter { get; set; } = "";
    //    public string DataFormat { get; set; } = "";
    //    public string AntennaIdentification { get; set; } = "";
    //    public string PolarizationDirection { get; set; } = "";
    //    public string MeasurementPersonel { get; set; } = "";
    //    public string Note { get; set; } = "";
    //    public string DocumentIdentificationMark { get; set; } = "CP_DATA";
    //    public string Reserve { get; set; } = "";
    //    public ObservableCollection<DataItem>? DataItems { get; set; }
    //}
}
